﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Thread_test
{
    class Program
    {
        static int countA = 0;
        static int countB = 0;
        public static void A()
        {
            while(true)
            {
                countA++;
                Console.WriteLine("A:" + countA);
            }
        }

        public static void B()
        {
            while(true)
            {
                countB++;
                Console.WriteLine("B:" + countB);
            }
        }

        static void Main(string[] args)
        {
            //Thread a = new Thread(A);
            //Thread b = new Thread(B);

            //a.Priority = ThreadPriority.Highest;
            //b.Priority = ThreadPriority.Lowest;
            //a.Start();
            //b.Start();

            //FileInfo file = new FileInfo(@"D:\C#\Learn\test_3_28\Thread_test\kkk.txt");

            //string str = File.ReadAllText(@"D:\C#\Learn\test_3_28\Thread_test\kkk.txt");
            //Console.WriteLine(str);

            //DateTime t1 = DateTime.Now;
            FileStream readFileStream = new FileStream(@"D:\C#\资料.rar", FileMode.Open, FileAccess.Read);
            FileStream writeFileStream = new FileStream(@"D:\C#\资料_Copy.rar", FileMode.Create, FileAccess.Write);

            byte[] buff = new byte[1024];
            while(readFileStream.Read(buff,0,buff.Length)!=0)
            {
                writeFileStream.Write(buff, 0, buff.Length);
            }

            writeFileStream.Close();        // 先开后关，后开先关
            readFileStream.Close();

            DateTime t1 = DateTime.Now;

            // .....
            DateTime t2 = DateTime.Now;

            TimeSpan ts = t2.Subtract(t1);      // TimeSpan表示一个时间间隔
            Console.WriteLine(ts.TotalMilliseconds);    // 将时间间隔以ms输出

        }
    }
}
